package com.chhuang.bean.save;

import com.chhuang.core.valid.ValidationGroups;
import com.chhuang.utils.string.RegexpUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
import java.io.Serializable;

/**
 * @Description UserSo用户保存修改用实体
 * @Author Darren Huang
 * @Date 2022-12-22 9:53
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
@ApiModel(value = "UserSo用户保存修改用实体", description = "UserSo用户保存修改用")
public class UserSo implements Serializable {
    private static final long serialVersionUID = -1281052877171873277L;

    /**
     * 用户编号，修改用户信息时不能为空
     */
    @NotBlank(message = "{userId.not_blank}", groups = ValidationGroups.ModifyGroup.class)
    @ApiModelProperty(value = "用户编号，修改用户信息时不能为空")
    private String userId;

    /**
     * 用户名
     */
    @NotBlank(message = "{username.not_blank}",
            groups = {ValidationGroups.SaveGroup.class,
                    ValidationGroups.ModifyGroup.class})
    @Length(min = 1, max = 16, message = "{username.over_max_len}",
            groups = {ValidationGroups.SaveGroup.class,
                    ValidationGroups.ModifyGroup.class})
    @ApiModelProperty(value = "用户名", required = true)
    private String username;

    /**
     * 密码，新建用户时不能为空
     */
    @NotBlank(message = "{password.not_blank}", groups = ValidationGroups.SaveGroup.class)
    @Pattern(regexp= RegexpUtils.PASSWORD_WITH_NUM_AND_LET_SYM, message = "{password.valid_fail}",groups = ValidationGroups.SaveGroup.class)
    @ApiModelProperty(value = "密码，新建用户时不能为空")
    private String password;

    /**
     * 昵称
     */
    @Length(min = 0, max = 16, message = "{nickname.over_max_len}",
            groups = {ValidationGroups.SaveGroup.class,
                    ValidationGroups.ModifyGroup.class})
    @ApiModelProperty(value = "昵称")
    private String nickname;

    /**
     * 姓
     */
    @ApiModelProperty(value = "姓")
    private String lastname;

    /**
     * 名
     */
    @ApiModelProperty(value = "名")
    private String firstname;

    /**
     * 性别：男1，女0
     */
    @ApiModelProperty(value = "性别：男1，女0")
    private Byte gender;

    /**
     * 手机号
     */
    @NotBlank(message = "{phone.not_blank}",
            groups = {ValidationGroups.SaveGroup.class,
                    ValidationGroups.ModifyGroup.class})
    @Pattern(regexp = RegexpUtils.MOBILE_PHONE_REGEXP, message = "{phone.valid_fail}",
            groups = {ValidationGroups.SaveGroup.class,
                    ValidationGroups.ModifyGroup.class})
    @ApiModelProperty(value = "手机号", required = true)
    private String phone;

    /**
     * 电子邮箱号
     */
    @NotBlank(message = "{email.not_blank}",
            groups = {ValidationGroups.SaveGroup.class,
                    ValidationGroups.ModifyGroup.class})
    @Pattern(regexp = RegexpUtils.EMAIL_REGEXP, message = "{email.valid_fail}",
            groups = {ValidationGroups.SaveGroup.class,
                    ValidationGroups.ModifyGroup.class})
    @ApiModelProperty(value = "电子邮箱号", required = true)
    private String email;

    /**
     * 头像
     */
    @ApiModelProperty(value = "头像")
    private String photo;
}
